The present invention relates to a translation module for a machine control, a processing module for a machine control and a control system for controlling a machine.
Control systems having machine controls are used in automation engineering, inter alia. For motion control, this involves primarily machine controls being implemented that are configured as numerical controls (NC) or computerized numerical controls (CNC). A machine control configured as an NC or CNC control typically reads in information about the movements of the machine that are to be executed from a control program and uses this information to produce setpoint values for position controllers of the machine, wherein the position controllers control the position and movements of the machine components. Typically, the setpoint values are produced and output cyclically with a fixed cycle time.
NC controls are typically programmed by means of an imperative programming language, wherein a loaded control program is executed once after starting at runtime. A prevalent programming language for programming machine controls configured as NC controls is the language G code, as described in the industrial standard ISO 6983. G code allows a movement that is to be executed by the machine to be defined by means of geometric elements such as continuous lines or circle segments. A disadvantage of standard-compliant G code, however, is the limited scope of language thereof for available geometric elements and the large absence of high-level language elements. As such, named variables, progressive control flow instructions such as multiple case distinctions, and named and/or parameterized functions cannot be used or can be used only to a limited extent. Native and user-defined data types, such as multidimensional arrays, pointers, structures, lists and character strings are not available. The programming paradigm of object-oriented programming cannot be applied.
Beside NC controls for position control, programmable logic controllers (PLC) are also used in automation engineering. Programmable logic controllers are used in process control engineering, inter alia, for example for controlling production lines or chemical installations. Machine controls configured as programmable logic controllers control or regulate machines and installations by virtue of actuators such as relays, drives or valves being controlled on the basis of measured values that have been captured by sensors arranged on the machine or the installation.
Programmable logic controllers normally operate on an event-controlled basis and execute a control program periodically. Within an execution cycle, the signals of the sensors are then read in and the signals are taken as a basis for computing and outputting output values for the actuators. Programming languages for machine controls configured as programmable logic controllers are standardized in the industrial standard IEC 61131-3, inter alia. One of these programming languages is structured text. Structured text is text based and comprises structuring capabilities based on high-level languages, inter alia, such as control flow instructions, for example.
The PLC languages of IEC 61131-3 have only limited suitability for motion control with NC controls. If, for example, NC commands are programmed in the PLC language by means of function blocks, this has the disadvantage that the cyclic pass through the control program and the repeated evaluation of the function blocks are resource-intensive and slow down program execution. Concurrent execution of NC control and programmable logic controller in which computations are relocated from the NC control to the programmable logic controller has the disadvantage that the communication required for this purpose between NC control and programmable logic controller slows down program execution as a whole and increases programming complexity.
It is an object of the present invention to allow improved control of machines. In particular, the invention is intended to allow machine control that can be programmed flexibly, simply and efficiently and at the same time allows fast, resource-saving execution of control programs.
This object is achieved by a translation module for a machine control according to claim 1, a processing module for a machine control according to claim 10 and a control system for controlling a machine according to claim 20. Further advantageous embodiments are respectively indicated in the dependent claims.
A translation module for a machine control is configured to process an input program code of a control program and to produce therefrom a uniform intermediate representation having work instructions for execution by the machine control. The input program code in this case comprises a first program code component and a second program code component, wherein the first program code component is written in a first programming language and the second program code component is written in a second programming language. The work instructions of the intermediate representation comprise a first work instruction and a second work instruction, wherein the first work instruction is produced on the basis of the first program code component and the second work instruction is produced on the basis of the second program code component.
Such a translator module advantageously allows language elements of the first programming language and of the second programming language to be combined when the control program is created. A programmer who has a command of both programming languages can therefore easily express language elements or structures that are not on hand in one of the programming languages by using those of the other programming language. Language elements of a programming language are all the meaningful units of a program code written in the programming language, for example instructions, declarations, assignments, control flow instructions, expressions, variables, keywords, numbers or strings. The language elements can be allocated symbols of the grammar of the relevant programming language.
The first program code component composed in the first programming language comprises character sequences that respectively represent symbols of the first programming language, and the second program code component composed in the second programming language comprises character sequences that respectively represent symbols of the second programming language. These symbols may be nonterminal symbols such as instructions, expressions, assignments, declarations or control flow instructions. The symbols may also be terminal symbols, for example literals, such as numbers or strings, descriptors, keywords or special characters. Terminal symbols can also be referred to as basic symbols of the respective programming language.
A character sequence of the input program code represents a nonterminal symbol of the first or the second programming language if the character sequence or a series of basic symbols that is represented by the character sequence can be derived from the nonterminal symbol according to the rules of the first or the second programming language. If the character sequence can be derived from the nonterminal symbol, then it can also be stated that the character sequence comprises the nonterminal symbol.
The first program code component and the second program code component may be interleaved in one another. This means that, in the input program code, a character sequence of the first program code component can be followed by a character sequence of the second program code component and the character sequence of the second program code component can in turn be followed by a character sequence of the first program code component. Similarly, the input program code can comprise further program code components that are written in the first programming language or in the second programming language.
The first programming language can allow, by way of example, imperative programming of the machine control and be designed so that a control program is executed once at execution time. The first programming language may be a programming language that is optimized for motion control, for example, but that has only a limited scope of language for control flow instructions or the use of variables or functions. In particular, the first programming language may be the language G code.
The second programming language may be a programming language that is optimized for use in programmable logic controllers, for example. The second programming language can in this case comprise high-level language elements that allow the use of named variables, of named functions having formal parameters or of control flow instructions, for example. In particular, the second programming language may be one of the PLC languages of the industrial standard IEC 61131-3, for example the language structured text.
The uniform intermediate representation is based on all the control instructions expressed by the first program code component and the second program code component of the input program code. Thus, the two parts of the control program that are formed by the first program code component and the second program code component are combined in the intermediate representation. The intermediate representation may be available, by way of example, in a form suitable for fast and efficient execution by the machine control, for example in an object-oriented form.
The first and second program code components composed in the first programming language and the first and second program code components composed in the second programming language can be combined in the uniform intermediate representation as work instructions to be executed sequentially. The effect advantageously achieved thereby is that control instructions coded in the first and second program code components can be handled by the machine control in the correct order of handling. Similarly, an advantageously simple interchange of data between parts of the control program that are formed by the first program code component and parts of the control program that are formed by the second program code component is made possible.
In the case of one embodiment of the translation module, the translation module comprises a resolution module that is configured to read in the first program code component and the second program code component from the input program code and to convert them into basic symbols. The resolution module is configured to adopt a first state and a second state. In this case, the resolution module in the first state converts the first program code component into basic symbols of the first programming language. The resolution module in the second state converts the second program code component into basic symbols of the second programming language.
Such a resolution module for reading in the input program code allows, in an advantageously simple manner, a translation module to be realized that converts an input program code having program code components of the first programming language and having program code components of the second programming language into a uniform intermediate representation. By way of example, ambiguous character sequences can exist that represent or depict a basic symbol both in the first programming language and in the second programming language, but respectively have different meanings in the two programming languages, that is to say can be converted into different basic symbols. By virtue of the resolution module respectively adopting one of the two states for the conversion of character sequences of the first program code component and of character sequences of the second program code component and using either basic symbols of the first programming language or basic symbols of the second programming language for the conversion, depending on the state, it is advantageously possible to make certain that ambiguous character sequences of this kind are always converted into basic symbols of the respectively used programming language.
A resolution module that is configured to adopt the first and the second state when program code components of an input program code are converted into basic symbols may be configured as a finite machine, for example. Beside the first and the second state, it is also possible for a finite number of further states of the resolution module to exist.
In the case of one embodiment of the translation module, the resolution module is configured to execute a state transition from the first state to the second state when a first control sequence is read in from the input program code and to execute a state transition from the second state to the first state when a second control sequence is read in from the input program code.
The first or the second control sequence can consist, by way of example, of a single character, for example a special character, or of a character sequence having multiple characters. The first and the second control sequence can consist of different or the same characters or character sequences.
The first control sequence can consist of a character or a character sequence that does not represent a basic symbol of the first programming language. Similarly, the second control sequence can consist of a character or a character sequence that does not represent a basic symbol of the second programming language. In these cases, reading-in of the first or the second control sequence by the resolution module merely initiates a state transition by the resolution module. Alternatively, the first control sequence or the second control sequence can also represent a basic symbol of the first or the second programming language. The resolution module in these cases produces the represented basic symbol, and executes a state transition, when the first or second control sequence is read in.
The use of the first and the second control sequence allows the first program code component and the second program code component in the input program code to be easily distinguished from one another. This allows the input program code to be explicitly resolved into basic symbols of the first and the second programming language and allows conflicts on account of ambiguous character sequences in the input program code to be precluded.
In the case of one embodiment, the translation module comprises a parser module that is configured to create a uniform structure tree of the control program from the basic symbols, wherein the parser module is configured to execute a syntactic check on the input program code on the basis of a combined grammar. In this case, the combined grammar comprises rules of a first grammar of the first programming language and rules of a second grammar of the second programming language.
The rules that the combined grammar comprises from the first and second grammars can prescribe, by way of example, the manner in which character sequences that are respectively valid in the first or in the second programming language and that represent instructions, expressions, assignments, keywords, for example from control flow instructions, or numbers and descriptors, for example, are formed. Hence, these character sequences that are valid in the first or the second programming language also again form valid character sequences of the combined grammar. In this respect, the combined grammar defines a programming language that is a combination of the first and the second programming language and can therefore also be referred to as a combination language. In addition to the rules of the first grammar and the rules of the second grammar, the combined grammar can comprise rules according to which symbols of the first programming language can be combined with symbols of the second programming language.
The syntactic check on the input program code by the parser module advantageously allows the input program code to be checked completely for syntactic correctness when it is actually read in. In this case, completely means particularly that both errors with respect to the first grammar and errors with respect to the second grammar and possibly also errors that are based on differences in rules for combining the first and second grammars can be identified. The syntactic check by the parser module of the translation module can be executed at loading time for the control program, for example. This advantageously safely precludes interruptions in the control program at execution time on account of syntactically erroneous input program codes.
In this case, the uniform structure tree comprises all the basic symbols produced from the input program code by the resolution module, and also nonterminal symbols of the combined grammar. The nonterminal symbols are in this case produced by the parser module from the series of basic symbols. If the rules of the combined grammar comprise rules according to which symbols of the first programming language can be combined with symbols of the second programming language, then a first node of the structure tree that is associated with a symbol of the first programming language can have a second node, as a child node, that is associated with a symbol of the second programming language. Similarly, a node of the structure tree that is associated with a symbol of the second programming language can have, as a child node, a node associated with a symbol of the first programming language. The structure tree can thus comprise particularly a subtree that firstly comprises symbols of the first programming language and that secondly includes a subtree comprising symbols of the second programming language.
In the case of one embodiment of the translation module, the first programming language is G code and/or the second programming language is structured text. The language G code is advantageously particularly suitable for composing control programs for a machine control for motion control. The limited scope of language of G code, for example with respect to variables, data types, functions and control flow instructions, can advantageously be compensated for when writing the input program code by virtue of the relevant language elements of the language structured text being used for these elements. Since both languages are programming languages that are widely used for programming machine controls, a programmer familiar with programming machine controls can advantageously create, without great effort for learning and acquaintance, control programs that combine program code components or language elements of the language G code and the language structured text.
In the case of one embodiment of the translation module, the input program code comprises a series of instructions having a first instruction and a second instruction, wherein the first program code component comprises the first instruction and the second program code component comprises the second instruction and wherein the first instruction consists of a G code sentence and the second instruction consists of an ST instruction.
In this case, the ST instruction is written in the programming language structured text, and the G code sentence is written in the programming language G code. The ST instruction may be, according to the rules of the grammar of structured text, a language element such as an assignment, a control flow instruction or a function call, for example. An assignment can in turn comprise an expression, for example. A G code sentence consists of a series of G code words, wherein the G code words generally comprise an address letter and a value. The value can consist of a number or be provided by an expression that can be evaluated to form a number. The expression can include one or more computation operations such as multiplication or addition, for example.
By virtue of the translation module of a machine control being configured to process an input program code having a series of instructions that consist of ST instructions and G code sentences, the machine control can advantageously be controlled by an input program code that includes a mixture of instructions of the two programming languages. By way of example, the machine control may be configured to execute ST instructions and G code sentences respectively in the order in which the respective instructions are included in the input program code.
In the case of one embodiment of the translation module, the input program code comprises a G code word having an address letter and a value, wherein the first program code component comprises the address letter and the second program code component comprises the value, and wherein the value comprises an ST expression. In the ST expression, it is advantageously possible for ST variables or ST functions to be used for computing the value of the G code word. This allows, inter alia, the value used in the G code word to be computed dynamically by means of the ST expression at the runtime of the control program and, by way of example, current process variables to be incorporated into the computation of the value. This extends the scope of language of the language G code, for which it is usually possible to use only constant values, i.e. values available at the loading time for the control program.
In the case of one embodiment of the translation module, the input program code comprises a G code word having an address letter and a value, wherein the first program code component comprises the address letter and the value and the value comprises an ST variable. By virtue of the translation module being configured to process an input program code having a G code word whose value comprises an ST variable, it is advantageously possible for the current numerical value of the ST variable at execution time to be used for the execution of a control instruction of the control program that comprises the G code word. This allows, by way of example, the numerical value of the variable to be computed dynamically on the basis of process parameters available at runtime.
In the case of one embodiment of the translation module, the translation module comprises an analysis module, wherein the analysis module is configured to execute a semantic check on the input program code on the basis of a combined semantic system. In this case, the combined semantic system comprises stipulations of a first semantic system of the first programming language and stipulations of a second semantic system of the second programming language.
The semantic analysis can involve, by way of example, a check on the input program code in respect of purity of type for the included expressions, in respect of the association of names for variables and functions used or in respect of the correct use of functional parameters being executed. The combined semantic system can in this case comprise not only the stipulations of the semantic system of the first programming language and the stipulations of the semantic system of the second programming language but also further stipulations that regulate the combination of basic symbols of the first programming language with those of the second programming language. The analysis module can execute the semantic analysis of the input program code at the loading time of the control program and before execution of the control program. This advantageously allows static-semantic errors to be identified at loading time and, in particular, it to be precluded that execution of the intermediate representation of the control program needs to be interrupted or terminated at execution time on account of semantic errors.
In the case of one embodiment of the translation module, the translation module comprises a memory allocation module, wherein the memory allocation module is configured to allocate a memory address of a memory of a control system comprising the machine control to a variable included in the input program code. By virtue of the variables used in the input program code being assigned to the memory addresses before creation of the intermediate representation, it is possible for an intermediate representation to be produced that can advantageously be executed efficiently. In particular, the complexity for memory management at the execution time of the control program is reduced.
A processing module for a machine control is configured to process an intermediate representation having work instructions and to take the work instructions as a basis for producing control commands for controlling a machine connected to the machine control. In this case, the processing module comprises an execution module and an NC processor, wherein the execution module is configured to take the work instructions of the intermediate representation as a basis for producing an NC instruction and to transfer the latter to the NC processor, and wherein the NC processor is configured to take the NC instruction as a basis for producing the control command.
The NC instruction can be produced by the execution module such that it can be expressed completely in one programming language. This programming language may be, by way of example, a programming language that has been used for writing an input program code on which the intermediate representation is based. If a combination language comprising a first and a second programming language has been used for writing the input program code, then the programming language on which the NC instruction is based may be the first programming language, for example.
The second programming language used for writing the input program code on which the work instructions are based can include, by way of example, language elements that are not comprised by the first programming language. These language elements may be, by way of example, high-level language elements, such as named variables, named functions having formal parameters or control flow instructions. The processing of the work instructions can involve the execution module evaluating these high-level language elements completely. The NC instruction can then be converted into the control command by the NC processor without memory access operations, evaluations of variables or evaluations of control flow instructions.
The execution module may be configured to evaluate variables or function calls comprised by the intermediate representation and to produce the NC instruction by using, rather than the variables or function calls, explicit numerical values that are obtained during the evaluation of the function or variables at the time of handling of the intermediate representation. As result, the NC instruction can advantageously comprise data obtained or produced during production of the control commands at the runtime of the control program even in a case in which the programming language on which the NC instruction is based does not support variables or functions.
The NC instruction may be based particularly on a programming language that does not comprise high-level language elements but is particularly suitable for the stipulation of movement instructions. This programming language may be, by way of example, the language G code and the execution module may be configured to produce NC instructions that can be expressed by G code. The NC processor may then essentially be configured as a G code interpreter or translator, for example. The processing of the intermediate representation by the execution module to form work instructions based on G code then advantageously allows the language G code to be extended by high-level language elements of another programming language, for example the language structured text.
In the case of one embodiment of the processing module, the execution module is configured to produce a further control command for controlling the machine. The execution module is thus configured to produce a control command without said control command being created by the NC processor on the basis of an NC instruction. This advantageously allows even control commands that cannot be expressed in the programming language used for depicting the NC instructions to be used for controlling the machine.
In the case of one embodiment of the processing module, the processing module comprises a sorting module that is configured to receive the control command and the further control command and to output the control command and the further control command in an order of actuation. The processing module may be configured, by way of example, so that the execution module and the NC processor are executed in parallel, so that the control command can be produced by the NC processor and the further control command can be produced by the handling module concurrently.
By way of example, the execution module is able, after it has transmitted an NC instruction for producing the control command to the NC processor, to process a further work instruction of the intermediate representation, on the basis of which work instruction the execution module produces the further control command. Delays in the execution in NC processor or execution module can lead to the control command and the further control command not being output in the chronological order needed for motion control. In such a case, the sorting module advantageously makes certain that the control command and the further control command are transmitted to the machine that is to be controlled in accordance with the order of execution that is needed for the motion control for the machine.
In the case of one embodiment of the processing module, the execution module is configured to read data from a memory of a control system comprising the machine control and/or to write data to the memory. This advantageously allows the machine control to be able to process an input program code, of a control program, that comprises high-level language elements such as named functions having formal parameters or named variables. The content of the variables or parameters can be written to the memory or read from the memory at the execution time of the control program by the execution module. If the NC instructions transmitted to the NC processor are based on a programming language that does not comprise high-level language elements of this kind, then the processing module may also be configured so that only the execution module but not the NC processor can access the memory of the control system.
In the case of one embodiment of the processing module, the execution module is configured to receive a piece of status information about a status of the NC processor from the NC processor. This advantageously allows the respectively current status of the NC processor at execution time to be taken into consideration for the processing of the work instructions of the intermediate representation. By way of example, this allows conditions of control flow instructions to be based on the current status of the NC processor. The status information may be an activated coordinate transformation or tool information, for example.
In the case of one embodiment of the processing module, the intermediate representation comprises a series of object pointers to instruction objects, wherein the instruction objects refer to methods that include the work instructions. This advantageously allows object-based and particularly efficient handling of the intermediate representation by the execution module. The instruction objects can also include static data as attributes, wherein the data are used by the translation module and are read during the handling of the work instructions from the method.
In the case of one embodiment of the processing module, the work instructions are available as machine code. In the case of one embodiment of the processing module, the execution module is configured to transfer the NC instruction to the NC processor as a data structure, particularly as a binary data structure. This advantageously allows particularly fast and efficient handling of the work instructions by the execution module or of the NC instructions by the NC processor at the runtime of the control program. This advantageously makes certain that control commands for controlling the machine are always available even in the case of fast execution of machine movements.
In the case of one embodiment of the processing module, the NC instruction represents a G code sentence. This advantageously allows a movement instruction, represented by the NC instruction, for the machine that is to be controlled to be efficiently represented by a few parameters from geometric elements. This reduces the volume of data that is needed for depicting the NC instruction, and advantageously fast production of the control commands from the work instructions of the intermediate representation is made possible.
In the case of one embodiment of the processing module, the execution module is configured as a stack machine. In this case, the work instructions of the intermediate representation may respectively be stack commands that manipulate a runtime stack of the stack machine. An execution module configured as a stack machine allows particularly simple and efficient execution of the intermediate representation.
A control system for controlling a machine has a machine control, wherein the machine control comprises a translation module and a processing module. The translation module of the machine control may be configured, by way of example, to produce from the input program code the uniform intermediate representation having work instructions for processing by the processing module. The processing module may be configured to take the work instructions as a basis for producing control commands for controlling the machine. By virtue of the control system comprising the machine control with the translation module and the processing module, advantageously simple and fast processing and execution of the input program code with control sequences of the first and second programming languages is made possible.
The production of the uniform intermediate representation advantageously allows the input program code to be conditioned such that it can be executed continuously and essentially sequentially in an efficient and resource-saving manner at the runtime of the control program. Additionally, during the processing of the intermediate representation by the execution module of the processing module, it is possible for NC instructions to be produced, for example, that can be described completely by the first programming language. This advantageously allows the NC processor to be able to be optimized for the processing of the first programming language. Overall, the machine control of the control system thus allows, in an advantageously simple, efficient and resource-saving manner, an input program code to be processed for which the first programming language has been augmented by language elements of the second programming language, but wherein the production of the control commands by the NC processor is again based exclusively on the first programming language.
In the case of one embodiment of the control system, the control system comprises an NC core and a setpoint value channel. The NC core is configured to receive the control commands of the processing module, to take the control commands as a basis for producing setpoint values for the machine and to transfer the setpoint values to the machine via the setpoint value channel. Moreover, the machine control forms part of a user program environment of the control system and the NC core forms part of a realtime environment of the control system.
Like the NC instructions, the control commands can comprise parameterized geometric elements that describe the movement instructions for the machine that is to be controlled. As a result, the control commands comprise an advantageously small volume of data, which means that they can be transferred to the NC core particularly quickly. By virtue of the NC core converting the control commands into setpoint values, the information about the movements to be executed can advantageously be transferred in a form that can be processed particularly simply by one or more position controllers of the machine. Additionally, the NC core may be configured to condition the movement instructions parameterized by geometric elements. This can comprise, by way of example, interpolation of the machine movement to be executed at discrete points that are prescribed by the times at which the setpoint values are meant to be generated.
The control system may be configured to execute the modules of the user program environment and the modules of the realtime environment on a control computer and to respectively apportion computation time of the control computer to the modules of the realtime environment at stipulated intervals of time. The computation time can respectively comprise a stipulated period and respectively be permanently assigned to a module, so that it is certain that the relevant module of the realtime environment is not dispossessed of the computation time. As result, it is advantageously possible to make certain that output values of the modules of the realtime environment, for example setpoint values of the NC core, are produced continuously at fixed intervals of time.
The user program environment of the control program can comprise all the modules whose execution is not time critical, that is to say that do not have to be assigned a fixed proportion of the computation time of the control computer and that can also be dispossessed again of an execution time window if need be during the execution.
By virtue of the control system being configured so that the machine control forms part of the user program environment and the NC core forms part of the realtime environment, the number of computations to be executed by the realtime environment can advantageously be kept small. The processing of the input program code and the production of the intermediate representation by the translation module of the machine control, which may be relatively computation intensive, can advantageously be executed before actual execution of the control program. At execution time, it is then possible for the intermediate representation to be converted into control commands for the NC core by the processing module of the machine control in an advantageously efficient manner.
In the case of one embodiment of the control system, the control system comprises a memory and the machine control is configured to write data to the memory and/or to read data from the memory. This advantageously allows the machine control to be able to use named variables or named functions having parameters during the production of the control commands from the input program code of the control program, wherein the values of the variables or parameters can be stored in the memory. This advantageously allows a programming language that comprises variables or functions to be used for writing the input program code. The memory access can be effected by the execution module of the machine control, for example.
In the case of one embodiment of the control system, the control system comprises a PLC module, wherein the PLC module is configured to control the processing of the input program code of the control program by the machine control. Moreover, the PLC module is configured to interchange data with the memory.
The PLC module makes functions of a programmable logic controller available. The PLC module may be configured, by way of example, to prompt the loading, execution and termination of a control program by the machine control. Moreover, the PLC module may be configured to control functions of the machine or of an installation comprising the machine that do not comprise the actual motion control. By way of example, the PLC module may be configured to control and monitor an entire production process of an installation comprising the machine.
By virtue of the PLC module, like the machine control, being able to access the memory of the control system, the memory can be used to interchange data between the machine control and the PLC module in an advantageously simple manner. As a result, the PLC module can take into consideration status messages or current values of variables or parameters during the process control, for example. It is also possible for the PLC module to convey movement parameters that are meant to be taken into consideration during the handling of the control program to the machine control. These may be information about a workpiece to be machined or a tool to be used, for example.